//
//  Emoticon.swift
//  EmoticonKeyBoard
//
//  Created by apple on 15/12/26.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

class Emoticon: NSObject {
    //分组表情文件路径id 用来拼接文件路径
    var id: String?

    //用来向服务器发送表情文本
    var chs: String?
    //图片文件名称  本地替换表情文本
    var png: String?
    //emoji表情 对应的十六进制字符串
    var code: String?
    
    //增加emoji表情的计算型属性
    var emojiStr: String? {
        guard let codeStr = code else {
           return nil
        }
        
        return codeStr.emjiStr()
    }
    
    //定义计算性属性 计算图片路径
    var iamgePath: String? {
        // NSBundle.mainBundle() + Emoticons.bundle  + id + png
        let idpath: String = id ?? ""
        let pngpath: String = png ?? ""
        
        let path = (NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + "\(idpath)/" + "\(pngpath)")
        
        return path
    }
    
    //增加标记是否是删除按钮的标记
    var isDelete = false
    
    var isEmpty = false
   
    init(dict: [String : String]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
        
    }
    
    init(isDelete: Bool) {
        self.isDelete = isDelete
        super.init()
    }
    
    init(isEmpty: Bool) {
        self.isEmpty = isEmpty
        super.init()
    }
    //过滤无用字段
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }


    override var description: String {
        let keys = ["chs","png","code"]
        return dictionaryWithValuesForKeys(keys).description
    }


}
